
#ifndef _TTG_SERVICES_PERFORMER_INFO_
#define _TTG_SERVICES_PERFORMER_INFO_
#include "Common/Definitions.h"

#ifdef TTG_PL_VISUALIZER

#include "Common/Math.h"
#include "Common/Extras.h"
#include "Runtime.Low/Threads.h"

#include "PipelineTaskInfo.h"

namespace ttg_internal
{
	namespace pipeline
	{
		//Stores information about tasks, that were performed by one thread.
		class PerformerInfo
		{
			private:
				std::vector<PipelineTaskInfo> tasks;
				ttg::math::uint64 thread_id;
				ttg::threads::FastCriticalSection locker;
			public:
				//Creates information for performer (ID will be detected automatically).
				inline PerformerInfo()
				{ thread_id = ttg::threads::CurrentThread::getIdentifier(); }
				//Creates information for performer with given ID.
				inline PerformerInfo(ttg::math::uint64 ID)
				{ thread_id =  ID; }
				//Returns identifier of owner (probably, number of core, which performer is binded to).
				inline ttg::math::uint64 getID() const
				{ return thread_id; }
				//Adds information about performed task.
				void addTaskInfo(PipelineTaskInfo info);
				//Returns information about all performed tasks.
				std::vector<PipelineTaskInfo> getTaskInfo();
				//Clears all information.
				void clear();
				//Stores current information to xml ("Performer" section will be created).
				//In case of error throws Error().
				void store(ttg::extras::XMLTree &xml);
				//Creates PerformerInfo according to xml ("Performer" section is expected).
				//In case of error throws Error().
				static PerformerInfo *create(ttg::extras::XMLTree &xml);
		};
	}
}

#endif

#endif
